<#include "/admin/common/include/html_head.html"> <#include
"/admin/common/include/sysparam.html"> <#include
"/admin/common/include/pagination.html">

<div class="row-fluid">
	<div class="span12">
		<!-- BEGIN EXTRAS PORTLET-->
		<div class="portlet box">
			<div class="portlet-title">
				<div class="caption">
					<h5>主题设置</h5>
				</div>
			</div>
			<div class="portlet-body form">
				<form id="templateSearchForm"> 
					<div class="row-fluid"> 
						<div class="span6">
							<div class="dataTables_filter" id="sample_1_filter">
								<label>名称: <input type="text" aria-controls="sample_1"
									value="${(_QUERY_s_eq_name)?if_exists}"
									class="span1 m-wrap medium" name="_QUERY_s_eq_name"
									id="_QUERY_s_eq_name"></label>
							</div>
						</div>
					</div>
				</form>

				<div class="alert alert-error " id="errTip" style="display: none;"></div>
				<div class="alert alert-success " id="sucTip" style="display: none;"></div>
				<div class="tab-pane active" id="tab_1">
					<div class="portlet-body">
						<div class="clearfix">
							<button id="template_query_btn" class="btn blue">
								<i class="icon-search"></i>&nbsp;&nbsp;查询
							</button>
							<button id="template_add_btn" class="btn blue">
								<i class="icon-plus"></i>&nbsp;&nbsp;新增
							</button>
							<button id="template_del_btn" class="btn blue">
								<i class="icon-trash"></i>&nbsp;&nbsp;删除
							</button>
						</div>
						<br>
						<form action="${contextPath}/templatepackage/show.op" id="QueryForm">
							<table class="table table-striped table-bordered table-hover"
								id="templateTable">
								<thead>
									<tr>
										<th style="width: 8px;"><input type="checkbox"
											class="group-checkable" data-set="#templateTable .checkboxes" /></th>
										<th>主题名称</th>  
										<th>访问路径</th>  
										<th>是否有效</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<#list pageBean.result as tt >
									<tr class="odd gradeX">
										<td><input type="checkbox" class="checkboxes"
											value="${tt.id}" /></td> 
										<td><img
											src="${contextPath}${(tt.imageUrl)?if_exists}"
											width="80" height="80" /> ${tt.name} </td>  
										<td>${tt.prjUrl}</td>
										<td><@translate paramCode=iseffCode
											value=(tt.iseff)?if_exists /></td>
										<td><a href='#' name="edit_action" value="${tt.id}">编辑</a>
											<a href='${contextPath}/${templatePrefix}/${Session.USER_INFO_SESSION.id}/${tt.prjUrl}/index.html' target="_blank" name="preview_action">预览</a>
											<a href='#' name="publish_action" value="${tt.id}">发布</a>
											<a href='${contextPath}/${onlinePrefix}/${Session.USER_INFO_SESSION.id}/${tt.prjUrl}/index.html' target="_blank" value="${tt.id}">线上</a>
											</td>
									<tr></#list>
								</tbody>
							</table>
						</form>
						<@pagination searchFormId='templateSearchForm' pBean=pageBean />
					</div>
				</div>

			</div>
			<!-- END EXAMPLE TABLE PORTLET-->
		</div>
	</div>

</div>




<script>
	jQuery(document).ready(function() {
		tableAction.init({
			tableId : 'templateTable',
			queryUrl : '${contextPath}/templatepackage/show.op',
			deleteUrl : '${contextPath}/templatepackage/delete.op',
			editUrl : '${contextPath}/templatepackage/showEditForm.op',
			queryBtnId : 'template_query_btn',
			deleteBtnId : 'template_del_btn',
			searchFormId : 'templateSearchForm',
			isPopEditForm : false,
			editBtnId : 'template_add_btn'
		});

		$("a[name='publish_action']").bind("click", function() { 
			var id = $(this).attr("value");
			var url = '${contextPath}/publish/online.op'; 
			var requestData = { 
					"templatePackageId":id  
				};
			var dataListJson = JSON.stringify(requestData);
		 
			common.alert({
				content : '是否发布线上？',
				showAction : true,
				actionContent : '发布',
				actionFn : function() { 
					ajax.syncJsonRequest({
						url : url,
						param: dataListJson,
						success : function(data) {
							if (!data || !data.success) {
								$('#'+_errZoneId).html(data.retinfo);
								$('#'+_errZoneId).show();
								common.alert({
									content : '发布失败！'
								});
							}
							if (data.success) {
								common.alert({
									content : data.retinfo  
								});
							}
						}
					});
				}
			});
		});
	});
</script>

<#include "/admin/common/include/html_bottom.html">
